<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%out.clear(); %><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>欢迎访问用户中心 -- 用户登录</title>
		<link href="${pageContext.request.contextPath}/css/index.css" rel="stylesheet" type="text/css"/>
 	 	<script type="text/javascript" src="${pageContext.request.contextPath}/js/M.js"></script>
 	 	<script type="text/javascript" src="${pageContext.request.contextPath}/js/form.js"></script>
 	 	<script type="text/javascript" src="${pageContext.request.contextPath}/js/md5.js"></script>
</head>
<body onload="changeValidateCode(document.getElementById('randImg'));">
	<div class="content clearfix">
		<div class="login_form clearfix">
			<div class="pad_50 clearfix">
				<h4 align="center">欢迎登录用户中心</h4>
				<form method="post" action="userLogin.action" id="loginForm">
					<div class="marb_14 por_r" id="loginId">
						<input type="text" name="users.userName" value="${users.userName}" id="user" class="input_kuang item errortip" placeholder="邮箱/用户名" isRequired="true"
							/>
						<input type="text" class="input_kuang  errortip" style="display:none;color:#999;" value="邮箱/用户名" id="user_text" isRequired="true"
							rule="(^[\w.\-]+@(?:[a-z0-9]+(?:-[a-z0-9]+)*\.)+[a-z]{2,3}$)|(^1[3|4|5|8]\d{9}$)|(^\d{3,}$)" autocomplete="off" />
						<span class="littlepop">
						<!-- 错误提示小气泡 -->
						<span class="popmessage error_tip">
						<span class="error_icontwo"></span><span id="errorTip">用户名错误</span> </span>
						<span class="popmessage empty_tip"> <span class="error_icontwo"></span><span>请输入用户名称</span>
						</span><i class="little_corner"></i></span>
					</div>
					<div class="marb_14 por_r" id="loginPass">
						<input type="password" name="users.passWord" class="input_kuang item errortip" id="password" placeholder="密码"
							isRequired="true" rule="^.{6,}" autocomplete="off" />
						<!-- error_put为出现错误时的黄框 -->
						<input type="text" class="input_kuang  errortip" id="password_text" value="密码" style="color:#999;display:none;"
							isRequired="true" rule="^.{6,}" autocomplete="off" />
						<span class="littlepop"> <span class="popmessage error_tip">
						<span class="error_icontwo"></span>密码不符合规范 </span><span class="popmessage empty_tip">
						<span class="error_icontwo"></span>请输入密码
						</span> <i class="little_corner"></i></span>
					</div>
					<div class="sub_log clearfix">
						<div class="sub_login sub_log_bottom  flt_l">
							<input type="submit" class="no_bg" value="登录"  onclick="javascript:document.getElementById('password').value=Crypto.MD5(document.getElementById('password').value);"/>
						</div>
						<a href="#">忘记密码？</a>
					</div>
				</form>
			</div>
			<div class="ano_log">
			<b style="color: red; text-align: center;">${msg}</b>
				<a href="${pageContext.request.contextPath}/register" class="mt_login mart_10">立即注册</a>
			</div>
			<div class="ano_span_t"></div>
		</div>
	</div>
	<script>
		var msg = ${msg};
		if (msg.length > 0) {
			M.getEl("#loginId").addClass("error");
			M.getEls("input").doApply("addListener", "focus", function() {
				M.getEl("#loginId").removeClass("error")
				M.getEl("#errorTip").html("用户名错误");
			});
			M.getEl("#errorTip").html(msg);
		}
	</script>
	<script>
		M.getEl("#loginForm").addListener(
				"submit",
				function() {
					var userName = M.getEl('#user').val();
					var date = new Date();
					date.setTime(date.getTime() + 1 * 24 * 3600 * 1000);
					document.cookie = "userName=" + escape(userName)
							+ "; expires=" + date.toGMTString();
				}).validate(true);

		;
		(function() {
			var pt = document.getElementById("passToken");
			var c = document.cookie.split(";");
			var p = "", userName = '';
			for ( var i = 0; i < c.length; i++) {
				if (c[i].indexOf("passToken") > -1) {
					p = c[i].substring(c[i].indexOf("=") + 1);
					break;
				}
				if (c[i].indexOf("userName") > -1) {
					userName = c[i].substring(c[i].indexOf("=") + 1);
					M.getEl('#user').val(unescape(userName));//.dom.focus()
					break;
				}
			}
			pt.value = p;

		})();
	</script>
	<script>
		if (!M.ability.placeholder) {
			var user = M.getEl("#user");
			var userText = M.getEl("#user_text");
			var pass = M.getEl("#password");
			var passText = M.getEl("#password_text");
			if (user.val() == "") {
				user.hide();
				userText.show();
			}
			if (pass.val() == "") {
				pass.hide();
				passText.show();
			}
			userText.addListener('focus', function() {
				this.hide();
				user.show();
				user.dom.focus();
			});
			user.addListener('blur', function() {
				if (this.val() == "") {
					this.hide();
					userText.show();
				}
			});
			passText.addListener('focus', function() {
				this.hide();
				pass.show();
				pass.dom.focus();
			});
			pass.addListener('blur', function() {
				if (this.val() == "") {
					this.hide();
					passText.show();
				}
			});
		}
	</script>
</body>
</html>